Daniel Prazeres
Daniel Prazeres
TTypebot
Created by Daniel Prazeres on 5/12/2025 in #help-and-questions
OpenAI Assistant - Function Calling
Should I be using the HTTP Request block separately and connect it somehow to the Ask Assistant? Because I only have the information “name” (it’s a example) during the conversation between the agent and the customer. My goal is trigger an agent function, send an information and retrieve an information, give that response to the agent and then answer the customer.
10 replies
TTypebot
Created by Daniel Prazeres on 5/12/2025 in #help-and-questions
OpenAI Assistant - Function Calling
No description
10 replies
TTypebot
Created by Daniel Prazeres on 5/12/2025 in #help-and-questions
OpenAI Assistant - Function Calling
What’s happening: When I type: “Hi! My name is Daniel. What is my surname?” The assistant responds: ❌ “There was an error trying to retrieve your surname…” BUT: • The API is called (confirmed in FastAPI logs) • It returns 200 OK • The response is { "sobrenome": "Prazeres" } So everything seems fine on the backend. Has anyone encountered something like this? Am I missing something in the assistant config or function setup? Thanks in advance 🙏
10 replies
TTypebot
Created by Daniel Prazeres on 5/12/2025 in #help-and-questions
OpenAI Assistant - Function Calling
OpenAI function JSON:
{
"name": "capturar_nome",
"description": "Captura o nome do usuário e envia para uma API externa.",
"strict": false,
"parameters": {
"type": "object",
"properties": {
"nome": {
"type": "string",
"description": "O nome do usuário"
}
},
"required": ["nome"]
}
}
{
"name": "capturar_nome",
"description": "Captura o nome do usuário e envia para uma API externa.",
"strict": false,
"parameters": {
"type": "object",
"properties": {
"nome": {
"type": "string",
"description": "O nome do usuário"
}
},
"required": ["nome"]
}
}
10 replies
TTypebot
Created by Daniel Prazeres on 5/12/2025 in #help-and-questions
OpenAI Assistant - Function Calling
Typebot function code:
try {
const response = await fetch("https://21f3-181-81-108-115.ngrok-free.app/receber-nome", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ nome: nome })
});

const json = await response.json();
const sobrenome = json.sobrenome;

setVariable("sobrenome_usuario", sobrenome);
return `Seu sobrenome é ${sobrenome}. Está correto?`;

} catch (error) {
return `Erro ao buscar sobrenome: ${error.message}`;
}
try {
const response = await fetch("https://21f3-181-81-108-115.ngrok-free.app/receber-nome", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ nome: nome })
});

const json = await response.json();
const sobrenome = json.sobrenome;

setVariable("sobrenome_usuario", sobrenome);
return `Seu sobrenome é ${sobrenome}. Está correto?`;

} catch (error) {
return `Erro ao buscar sobrenome: ${error.message}`;
}
10 replies
TTypebot
Created by Daniel Prazeres on 5/12/2025 in #help-and-questions
OpenAI Assistant - Function Calling
FastAPI backend:
from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()

class NomeRequest(BaseModel):
nome: str

@app.post("/receber-nome")
def receber_nome(payload: NomeRequest):
nome = payload.nome.lower()
sobrenomes = {
"daniel": "Prazeres",
"joão": "Silva",
"maria": "Souza"
}
sobrenome = sobrenomes.get(nome, "Desconhecido")
print(f"Nome recebido: {payload.nome}. Sobrenome retornado: {sobrenome}")
return { "sobrenome": sobrenome }
from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()

class NomeRequest(BaseModel):
nome: str

@app.post("/receber-nome")
def receber_nome(payload: NomeRequest):
nome = payload.nome.lower()
sobrenomes = {
"daniel": "Prazeres",
"joão": "Silva",
"maria": "Souza"
}
sobrenome = sobrenomes.get(nome, "Desconhecido")
print(f"Nome recebido: {payload.nome}. Sobrenome retornado: {sobrenome}")
return { "sobrenome": sobrenome }
10 replies