Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!