Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

116
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda