Help

Re: Data returned to Alexa skill

2148 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Donald_Irwin
4 - Data Explorer
4 - Data Explorer

I am working on an Alexa skill that executes a GET from an Airtable base where the record contains a field whose field type is Attachment. The GET in the Alexa skill assigns whatever is passed from Airtable to a variable. I don’t have a means of displaying the Alexa variable to see the contents. From the API documentation, I understand an attachment field will pass a field ID, the URL of the object and the file name of the object. Could someone provide an example of what is passed from the API using the following example:

AudioField=api_response.records.0.fields.AirtableAudioFile;

After execution, what is the contents of AudioField? Audiofield = ‘xxxxyyyyzzzz’

Thanks in advance for your reply!

6 Replies 6
openside
10 - Mercury
10 - Mercury

You should be able to see that information in the API docs.

If you visit your base, then in the upper right there is a ‘Help’ menu with an API documentation link. Click that and it will show exact data from your base and what it looks like.

Thanks for your reply. Yes. I have found this and have see the actual data as it resides in my base. I was wanting to know how this data is passed through the GET API. Are all three pieces of information (id, url and filename), passed at once with some sort of delimiter between each so that the desired information can be parsed once it is received? I am working on an Alexa skill and do not have a means of displaying this data received by the Alexa skill. If you are familiar with how this data is passed, I would be anxious to hear. Thanks.

Hmm, are you sure you went to the API documentation for your base? It shows you exactly what you get from the GET command. It doesn’t change anything. The data in the api documentation is making an actual api call and showing you exactly what you get returned.

Donald_Irwin
4 - Data Explorer
4 - Data Explorer

The API documentation is very helpful. I believe it is on my side of the API. The service I am using (Storyline) is not parsing the returned data object to provide only the URL to the object. My application does not care about the id of the field or the file name of the object. I will work with Storyline on getting this fixed. Thanks for all your comments.

The API documentation is very helpful. I believe it is on my side of the API. The service I am using (Storyline) is not parsing the returned data object to provide only the URL to the object. My application does not care about the id of the field or the file name of the object. I will work with Storyline on getting this fixed. Thanks for all your comments.

Dilip_Jain
4 - Data Explorer
4 - Data Explorer

hi there,
If Any one know please explain how to configure the airtable api in lambda function(Alexa developement).
And any one is know about how to turn on api access in alexa settings.
I am getting the json response in postman or in terminal but when i am running the code and testing in alexa skill there is no response of questions and showing me an error.

here is code of airtable of Airtable function js code

const request = require('request');
BASE_ID = `##############`;
TABLE_NAME = `##############`;
API_KEY = `##############`;

function getAirtable() {
    return new Promise((resolve, reject) => {
      request({
        url: `https://api.airtable.com/v0/${BASE_ID}/${TABLE_NAME}/?api_key=${API_KEY}`,
        json: true
      }, (error, response, body) => {
        if (!error && response.statusCode === 200) {
          resolve(body);
        } else
          reject("Cannot Reach Questions");
      });
    });
  };

async function testAirTable() {
    record = await getAirtable()
    console.log(`The first Easy Question is : ${record.records[0].fields.Easy}`);
    console.log(`The first Hard Question is : ${record.records[0].fields.Hard}`);
    console.log(`The first Answer is : ${record.records[0].fields.Answer}`);
    console.log(`There are ${record.records.length} Questions`);
};
testAirTable()

##############
here is code of index.js file of code lambda folder

BASE_ID = `###################`;

TABLE_NAME = `###################`;

API_KEY = `###################`;

var bigListofQuestions = {};

const LaunchRequestHandler = {

  canHandle(handlerInput) {

    return handlerInput.requestEnvelope.request.type === 'LaunchRequest';

  },

  async handle(handlerInput) {

    const attributesManager = handlerInput.attributesManager;

    // get attributes

    const attributes = await attributesManager.getPersistentAttributes() || {};

    // get the number of questions and update, minus 1 for array at zero

    bigListofQuestions = await getAirtable();

    attributes.totalQuestions = (Number(bigListofQuestions.records.length) - 1);

    console.log(`Total Number of Questions found was ${attributes.totalQuestions}`);

    if (attributes.userScore === undefined) {

      // setup new user if first time here

      attributes.questionAsked = false;

      attributes.currentAnswer = "";

      attributes.userScore = 0;

      attributes.timesAnswered = 0;

      attributes.listQuestionsAsked = [];

      attributes.questionsRight = 0;

      attributes.questionsWrong = 0;

      speechText = extMsg.WelcomeMsg;

      repromptText = extMsg.WelcomeMsg;

    } else {

      // else welcome back the user

      speechText = `<audio src='https://s3.amazonaws.com/ask-soundlibrary/foley/amzn_sfx_glasses_clink_01.mp3'/> Welcome back. You currently have ${attributes.userScore} points. You can say start a new game to reset your score. <break time='.3s'/> ${extMsg.getRandomShallWeBeginfirst()}`;

      repromptText = `Welcome back. ${extMsg.getRandomShallWeBeginfirst()}`;

      //reset in case we hard exited

      attributes.questionAsked = false;

      attributes.timesAnswered = 0;

      attributes.listQuestionsAsked = [];

    }

    attributesManager.setPersistentAttributes(attributes);

    await attributesManager.savePersistentAttributes();

    return handlerInput.responseBuilder

      .speak(speechText)

      .reprompt(repromptText)

      .getResponse();
  },
};