Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

112
Visualizações
Twilio Autopilot's custom channel Memory payload

I'm creating a web chat and I need to integrate an assistant using Twilio Autopilot, I use Autopilot's custom channels as follows:

  • I send a POST request to https://channels.autopilot.twilio.com/v2/{AccountSid}/{AssistantSid}/custom/webchat
  • I fill in these fields in the request data (Language=en-US, UserId=user123, Text=Something)
  • I add a Memory parameter in the Assistant URL

My backend code:

    // Assistant URL Memory parameter
    const context = JSON.stringify({
        accountHolder: "foo bar",
        balance: 123
    }, null, "");

    // Request params
    const urlencoded = new URLSearchParams();
    urlencoded.append("Language", "en-US");
    urlencoded.append("UserId", message.Author);
    urlencoded.append("Text", message.Body);

    const requestConfig: AxiosRequestConfig = {
        headers: {
            "content-type": "application/x-www-form-urlencoded",
            "accept": "application/json",
            "authorization" :  "Basic " + Buffer.from(accountSid + ":" + authToken).toString("base64")
        },
        method: "POST",
        url: `https://channels.autopilot.twilio.com/v2/${accountSid}/${assistantSid}/custom/webchat?Memory=${context}`,
        data: urlencoded
    };

    // Trigger the bot
    const twilioResponse = this.httpService.request(requestConfig);

    const result = await lastValueFrom(twilioResponse.pipe(map((response) => response.data)));

Twilio function:

exports.handler = async function(context, event, callback) {
  console.log(event.Memory);
  const userData = JSON.parse(event.Memory); // Memory does not contains my payload !

  return callback(null, {
    "actions": [
      {
        "say": `Hello ${userData.accountHolder}, your balance is ${userData.balance}`
      },
      {
        "listen": true
      }
    ]
  });
};

My problem is, The Memory parameter is not sent to the function

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I had a similar problem trying to pass the payload in and reached out to a Twilio support.

The answer I received was: "As per the present update from our engineering team, they are not looking at implementing the Memory parameter on V2 endpoint as there are very less users consuming it. You will have to use V1 endpoint for Autopilot if you are looking to use URL Parameter "Memory" for your use case. "

Therefore the URL will need to look like so: https://channels.autopilot.twilio.com/v1/ACxxx/UAxxx/custom/chat?Memory={"CarModel":"Diablo","CarMake":"Lamborghini","CarYear":"2019"}'

about 4 years ago · Juan Pablo Isaza Relatório

0

Twilio developer evangelist here.

I would have thought you might want to URL encode the JSON memory when you add it to the URL. Try this:

    const context = encodeURIComponent(
      JSON.stringify({
        accountHolder: "foo bar",
        balance: 123
      }, null, "")
    );
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda