How to make a post(json) request in IVRFlow fop2 in Issabel - issabel

I have this canvas in IVRFlow in fop2 in Issabel, i want to make a post(json) request to an api, but i can't do it.
here i set the codlink variable before to send it to the api:
this is the api call, the api need to recieve a codlink variable to make the request:
at the last in need to play the api answer, the api answer is like this:
[
{
"Mensaje": "Si su zona se encuentra sin Luz marque 1. Si se encuentra sin luz individual marque 2. \r\n\t\t\t\t\t\t\t\tSi registra problemas de alta tension marque 3.",
"Error": null,
"Codigo": "200",
"Identificador": "18135002001273"
}
]
here i try to play the Mensaje variable's content, but it doesnt work:
how can resolve it?

Related

Trigger action without user utterance

I want to write a Google Home action that tells the latest value of a field in a DB table. (Another service will keep updating the DB.)
How do I make Google Home speak the update automatically every 10 seconds without further user utterance after the Action is launched?
Interaction would be like this:
User: "OK Google, start Progress Updater"
Google Home: (Every X seconds) "10 percent."
Google Home: "19 percent"
...
Google Home: "100 percent."
Google Home: *"Task is complete!"
End of interaction
I know how to do it if a user has to say every time "Google Home, get me update".
Is there a way to do it in an automatic loop?
Tried following code based on response from #Prisoner
conv.ask(new MediaObject({
name: 'Jazz in Paris',
url: 'https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3',
description: 'A funky Jazz tune',
icon: new Image({
url: 'https://storage.googleapis.com/automotive-media/album_art.jpg',
alt: 'Media icon',
}),
}));
});
The best tool that we have to do this is the Media prompt.
Under this scheme, when you return any progress except for "complete", you'll include a Media object with a 10 second audio. When the audio finishes playing, you'll get a MEDIA_STATUS result, indicating the audio has finished. You can then check the status and reply accordingly, possibly including another Media in your prompt.

How to create a case in a Salesforce Account using REST API and python Script

I need some help. I need to create a case in a Account with all the details basically, all the fields, using REST API but it I am not able to figure out, how to insert a record for creating a case.
Could you please guide me, how to create a case using REST API in Salesforce?
Do you use a library such as https://pypi.org/project/simple-salesforce/0.3/ or do you need to craft the REST messages manually?
You'd need to do it in 2 calls, login first (unless you have session id already) and then
POST to
https://yourinstance.my.salesforce.com/services/data/v48.0/sobjects/Case
with header
Authorization Bearer <session id goes here, sometimes called "access token" too>
and body
{
"Subject": "Hello world",
"Description": "Lorem ipsum dolor sit amet...",
"Origin":"Web",
"AccountId" :"0010g00001mbqU4"
}
should work like a charm (pass an account id value right for your org and you might have more fields to fill in).
So now "only" how to log in. That's a bigger topic and depends if it's a backend thing or you'll have a human interacting with it, maybe logging in to SF and then coming back to your org. There's bit of reading on that (simpler if you'd use SOAP API to log in)
For example this would work if I didn't redact all sensitive stuff
POST to
https://login.salesforce.com/services/oauth2/token
with header
Content-Type application/x-www-form-urlencoded
and body
grant_type=password
&client_id=(ask your admin for "connected app")
&client_secret=(ask your admin for "connected app")
&username=redacted%40example.com
&password=redacted
Should return
{
"access_token": "<session id here, use it as Authorization header in next calls>",
"instance_url": "<use this as base url of all next calls>",
"id": "<call GET to this (with the Auth header) to learn more about user",
"token_type": "Bearer",
"issued_at": "1593684589157",
"signature": "redacted"
}
Again - don't do it all by hand if you can, use one of Python libraries for Salesforce.
from simple_salesforce import Salesforce
sf = Salesforce(
username='user name of salesforce account',
password='password',
security_token='token')
Sample data
data ={
"Name" : "ABCD",
"Contact" : "123456789",
"Description":"Radio has damaged because of handling."
}
create record
x = sf.Account.create(data)

Can somebody use my service since another server? Angular 9

I'm learning angular and have question about security. I'm using angular 9.
Can somebody use my service since another server?
I say this because I worry other person use service url to access my data base.
For example:
This is my controller in asp.net
[HttpGet]
[Route("api/Producto/listarProductos")]
public IEnumerable<ProductoCLS> listarProductos()
{
using (BDRestauranteContext bd=new BDRestauranteContext())
{
List<ProductoCLS> lista = (from producto in bd.Producto
join categoria in bd.Categoria
on producto.Iidcategoria equals
categoria.Iidcategoria
where producto.Bhabilitado == 1
select new ProductoCLS
{
idproducto = producto.Iidproducto,
nombre = producto.Nombre,
precio =(Decimal)producto.Precio,
stock =(int) producto.Stock,
nombreCategoria = categoria.Nombre
}).ToList();
return lista;
}
}
This is my service in angular:
public getProducto() {
return this.http.get(this.urlBase + 'api/Producto/listarProductos');
}
You need to add authorization logic to both your client and server side.
From Angular side
https://jasonwatmore.com/post/2018/09/07/angular-6-basic-http-authentication-tutorial-example
From Dot Net Core side
https://jasonwatmore.com/post/2018/09/08/aspnet-core-21-basic-authentication-tutorial-with-example-api
Once you login - you will get an 'authentication-token'. All your subsequent HTTP requests will have an 'Authorization' header and in the Server side - you need to configure it so that it only entertain those http requests which have the authorization headers.
You can have on plethora of different authentication methods like Azure AD authentication, Facebook, Google, github etc.

Azure AD issues claims security groups names

I need my Azure AD to issue a claim with security group names.
But there are only group object ids come out in the JWT token.
How to get security group names?
What I did so far:
1. Created a test security group and assigned a user to it. This is the only group for this user.
Set the groupMembershipClaims to All (integer 7) as it is in this official document https://learn.microsoft.com/en-us/azure/active-directory/develop/reference-app-manifest
here is the relevant part of the application manifest:
{
...
"appRoles": [],
"availableToOtherTenants": false,
"displayName": "Azure AD B2C sandbox App ",
"errorUrl": null,
"groupMembershipClaims": "All",
"optionalClaims": null,
"acceptMappedClaims": null,...
You cannot get them in tokens. As you noticed, you only get the ids.
Usually this is good, since the id cannot be changed, unlike the name which can change.
If you want to do authorization based on groups, you can set the ids in a configuration file and then check with the id.
If you want the names for some other purpose, you'll need query the groups from Microsoft Graph API.
You can find the API documentation here: https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/groups-overview
You can get the AD group name thru Token configuration. By default, it is return Group ID but you can change it to sAMAccountName.
You can not receive group display names inside your id_token.
But you can query group properties, like group display name from another api, in this case ms graph api.
Here is what I did to query groups display name from ms graph api..
Thanks
/// <summary>
/// Translate group.Id list received on id_token into group.DisplayName list
/// </summary>
/// <param name="groupIdList"></param>
/// <returns></returns>
public override List<string> TranslateGroupNames(List<string> groupIdList)
{
// validations
if (groupIdList == null || groupIdList.Count == 0)
return groupIdList;
if (string.IsNullOrEmpty(Configuration.ClientID))
throw new InvalidOperationException("A configuração 'ClientID' não pode ser vazia.");
if (string.IsNullOrEmpty(Configuration.ClientSecret))
throw new InvalidOperationException("A configuração 'ClientSecret' não pode ser vazia.");
if (string.IsNullOrEmpty(Configuration.TokenEndpoint))
throw new InvalidOperationException("A configuração 'TokenEndpoint' não pode ser vazia.");
if (string.IsNullOrEmpty(Configuration.TenantID))
throw new InvalidOperationException("A configuração 'TenantID' não pode ser vazia.");
// acquire a brand new access_token via client_credentials, especificly to ms graph api
var clientCredentialsRequest = new ClientCredentialsTokenRequest();
clientCredentialsRequest.Address = Configuration.TokenEndpoint;
clientCredentialsRequest.ClientId = Configuration.ClientID;
clientCredentialsRequest.Scope = "https://graph.microsoft.com/.default";
clientCredentialsRequest.ClientSecret = Configuration.ClientSecret;
var accessTokenResponse = _httpClient.RequestClientCredentialsTokenAsync(clientCredentialsRequest).Result;
if (accessTokenResponse.IsError)
throw new InvalidOperationException($"Falha ao recuperar AcessToken. {accessTokenResponse.Error}: {accessTokenResponse.ErrorDescription}");
// set access_token on httpclient
_httpClient.SetBearerToken(accessTokenResponse.AccessToken);
var result = new List<string>(groupIdList.Count);
// query ms graph api to recover group info
foreach (var groupId in groupIdList)
{
var url = $"https://graph.microsoft.com/v1.0/{Configuration.TenantID}/groups/{groupId}";
var groupResponse = _httpClient.GetAsync(url).Result;
if (!groupResponse.IsSuccessStatusCode)
throw new InvalidOperationException($"Falha ao recuperar grupo. {groupResponse.ReasonPhrase}");
var jsonString = groupResponse.Content.ReadAsStringAsync().Result;
var group = JsonConvert.DeserializeObject<dynamic>(jsonString);
if (group?.displayName?.Value == null)
throw new InvalidOperationException($"Grupo inválido");
// get group display name
result.Add(group.displayName.Value);
}
return result;
}

Alexa Intent Swithing context

I am new to the Alexa Developing, i used ApiToBot third party application to create and build the intents and responses,
I used HTTPS method to contact the server.
Then i successfully deployed the project into the alexa developer account.
while i'm testing the application i stuck into the error.
Right now i have to Intent and their responses are from HTTPS server.
After opened the skill i received a welcome response, after that i called one intent i received response.
but i call second intent it is not showing the response and vise-versa.
Only one intent is working.
I hope this is your request and this was your response.
If that the case, your response has shouldEndSession parameter is set to true. What that means is that, once your response is read, Alexa will end the session and closes the skill. You are no longer inside the skill. Whenever you want Alexa to wait for user response, keep the session alive by setting shouldEndSession parameter set to false.
Ex: you response should be
{
"body": {
"version": "1.0",
"response": {
"outputSpeech": {
"type": "SSML",
"ssml": "<speak><p>Followers of user id 641 is [Martijn Verbove Anton Cooee Found Ryze Rebekah Radice Jonah Lupton Mila Chervenkova💪 David Morrison Tiep Vu Nicholas Tenhue Deepak Laxmi Narasimha Feda Jaan Lolly Daskal Hämorrhoiden selbst behandeln SF Ali Nicole Hardin Pradeep Chopra WhatUsersDo Alice Jones Arpit Maheshwari Мартин Стојчевски Pete Roome Dean Pikock.com Chad Scira Phil Hendrix] </p></speak>"
},
"shouldEndSession": false
}
}
}
Read this answer to know more about keeping the session alive using ask-nodejs-sdk
More info about Response Object here.

Resources